package com.echoesnet.echoesshortvideo.Persistence;

import android.arch.persistence.room.Database;
import android.arch.persistence.room.Room;
import android.arch.persistence.room.RoomDatabase;
import android.content.Context;


/**
 * Copyright (C) 2018 科技发展有限公司
 * 完全享有此软件的著作权，违者必究
 *
 * @author ben
 * @version 1.0
 * @modifier
 * @createDate 2018/4/19 20:33
 * @description
 */
@Database(entities = { TinyVideoInfoEntity.class}, version = 2, exportSchema = false)
public abstract class AppDatabase extends RoomDatabase
{
    private static volatile AppDatabase INSTANCE;

    public abstract TinyVideoInfoDao tinyVideoInfoDao();




   public abstract VideoDetailDao videoDetailDao();

    public abstract VideoPlayDao likeVideoDao();

    public abstract CommentListDao commentListDao();


    public static AppDatabase getInstance(Context context)
    {
        if (INSTANCE == null)
        {
            synchronized (AppDatabase.class)
            {
                if (INSTANCE == null)
                {
                    INSTANCE = Room.databaseBuilder(context.getApplicationContext(),
                            AppDatabase.class, "echoesVideo.db")
                            .build();
                }
            }
        }
        return INSTANCE;
    }

    public static void onDestroy()
    {
        INSTANCE = null;
    }
}
